import shutil
import os

# 将文件func2.log的内容拷贝至out.log
with open("out2.log", "r") as r_f, open("out2-back.log", "w") as w_f:
    shutil.copyfileobj(r_f, w_f, length=16 * 1024)

# 也可使用创建一个空的目标文件，原文件copy进去
shutil.copyfile("out2.log", "out2-back2.log")

# 拷贝压缩包 zhouruifu.zip  zhouruifu-back.zip
shutil.copyfile("zhouruifu.zip", "zhouruifu-back.zip")

# 仅拷贝文件权限
shutil.copymode("out2.log", "out2-back2.log")

# 当前目录下创建压缩文件'project_a.zip',包含内容为'D:\pyProject\temp'下文件
base_dir = "C:\Windows\Temp"
ret = shutil.make_archive("archive-file", "zip", base_dir=base_dir)
print(ret)

# 移动文件，从源'out.log'复制到'new_out.log'
shutil.move("out.log", base_dir + os.sep + "new_out.log")
